<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>报关行自主报价管理</title>
    <jsp:include page="../../head.jsp"/>
</head>
<script type="text/javascript" src="../js/ajaxutil.js"></script>
<script type="text/javascript">
    // 	var bstate = "${param.declaraState }";
    // 	var comId = "${sessionScope.CURRENT_USER.company.id}";
    var ID = "${declarationOffer.id}";
    var formSetting = {
        title: "查询报关报关行报价信息",
        module: 'save',
        numCount: 2,
        columns: [{
            name: "id",
            label: "id",
            hidden: true
        }, {
            name: "declaration_company",
            label: "报价公司",
            readonly: true
        }, {
            name: "declaration_amount",
            label: "出口报关金额",
            readonly: true
        }, {
            name: "imp_declaration_amount",
            label: "进口报关金额",
            readonly: true
        }, {
            name: "container_amount",
            label: "出口免报关费柜数",
            readonly: true
        }
            , {
                name: "imp_container_amount",
                label: "进口免报关费柜数",
                readonly: true
            }, {
                name: "price_begin_time",
// 			type : "date",
                label: "开始时间"
            }, {
                name: "price_end_time",
// 			type : "date",
                label: "结束时间"
            }, {
                name: "state",
                label: "审核状态",
                hidden: true
            }, {
                name: "remark",
                type: "textarea",
                colspan: "2",
                label: "出口备注"
            }, {
                name: "impRemark",
                type: "textarea",
                colspan: "2",
                label: "进口备注"
            }, {
                name: "review_reason",
                type: "textarea",
                colspan: "2",
                label: "确认结果反馈"
            }, {
                name: "upload_id.id",
                label: "upload_id",
                hidden: true
            }, {
                name: "declaration_company_id",
                label: "报价公司id",
                hidden: true
            }
        ],
        form: {
            'url': 'declarationOffer-reviewPlatformFare',
            'data': function () {
                var id = "${param.id}";
                if (id) {
                    var dataValue = "";
                    $.ajax({
                               url: "declarationOffer-find?id="
                                    + id,
                               async: false,
                               success: function (data) {
                                   dataValue = data;
                               }
                           });
                    return dataValue;
                } else {
                    return null;
                }
            },
// 			"ajaxForm":{
// 				success: function(){
// 					location.href = "declarationOffer-reviewPlatformFare?state=" + ID;
// 				}
// 			}
            'afterAjaxSuccess': function (responseText, statusText, xhr, $form) {
                location.href =
                        "declarationOffer-declarationOfferSupManage?id=${param.id}";
            }
        },

        buttons: {

            custom: [{
                id: "passBtn",
                value: "确认报价",
                click: function () {
                    $("input[name='state']").val("OS02");
                    $("#saveButton").click();
                }
            }, {
                id: "rejectBtn",
                value: "驳回报价",
                hidden: true,
                click: function () {
                    $("input[name='state']").val("OS03");
                    $("#saveButton").click();
                }
            }]
        }
    };
    $(document)
            .ready(
                    function () {
                        $("#formtable").mrdForm(formSetting);

                        var upload = $("input[name='upload_id.id']");
                        /*$("#attachmentFrame").attr(
                         "src",
                         "attach-main?id="
                         + (upload.val() == '' ? 'null' : upload
                         .val()));*/
                        $("#attachmentFrame").attr("src",
                                                   "/business/uploadMain?hide=1&type=offer#" + $(
                                                           "input[name='id']").val());

                        $("#attachmentFrame")[0].onload = function () {
                            $("#attachmentFrame").contents().find(
                                    "#mf_container0").hide();
                        };
                        var price_begin_time = $(
                                "input[name='price_begin_time']")
                                .val();
                        $("input[name='price_begin_time']")
                                .val(price_begin_time.substring(0, 10));
                        $("input[name='price_begin_time']")
                                .attr("readonly", true);
                        var price_end_time = $(
                                "input[name='price_end_time']")
                                .val();
                        $("input[name='price_end_time']").val(
                                price_end_time.substring(0, 10));
                        $("input[name='price_end_time']")
                                .attr("readonly", true);
                        $("textarea[name='remark']").attr("readonly", true);
                        $("#saveButton").hide();

                        var state = $("input[name='state']").val();
                        if (state != "OS01") {
                            $("#passBtn").hide();
                            $("#rejectBtn").hide();
                            $("textarea[name='review_reason']").attr("readonly",
                                                                     true);
                        }
                    });
</script>
<body>
<div id="formtable"></div>
<fieldset
        class="replace-ui-jqgrid ui-widget ui-widget-content ui-corner-all mf_con">
    <div
            class="replace-ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix table_header">
        <a href="javascript:void(0)"
           class="replace-ui-jqgrid-titlebar-close HeaderButton tab_button"><span
                class="ui-icon ui-icon-circle-triangle-s"></span> </a><span
            class="replace-ui-jqgrid-title">报价附件</span>
    </div>
    <iframe id="attachmentFrame" style="width: 100%;" scrolling="no"
            frameborder="0"
            onload=" this.height = (this.contentDocument.body.scrollHeight + 30);"></iframe>
</fieldset>
<%-- 	<input id="companyId" type="hidden" value="${companyId }"/> --%>
</body>
</html>
